package com.linked.universal.linkedutil;

import java.util.Random;
import java.util.concurrent.TimeUnit;

/**
 * @author :dbq
 * @date : 2023/3/17 9:14
 * @description : 给redisKey随机加上时间工具类
 */
public class RedisKeyRondomTime {
    private static Random random = new Random();

    /**
     * 生成0~60之间的数字
     */
    public static long toMinuteRondom() {
        return random.nextInt(60);
    }

    /**
     * 生成0~60之间的数字
     */
    public static long toHourRondom() {
        return random.nextInt(60);
    }

    /**
     * 生成0~24之间的数字
     */
    public static long toDayRondom() {
        return random.nextInt(24);
    }

    public static long toActiveRondom(int limitNumber) {
        return random.nextInt(limitNumber);
    }
    public static long getExtraTime(TimeUnit timeUnit){
        long extraNum;
        switch (timeUnit) {
            case DAYS:
                extraNum = toDayRondom();
                break;
            case HOURS:
                extraNum = toHourRondom();
                break;
            case MINUTES:
                extraNum = toMinuteRondom();
                break;
            default:
                extraNum = toActiveRondom(100);
                break;
        }
        return extraNum;
    }
}
